package com.zhuoshi.serviceImpl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zhuoshi.bean.WdHtBuild;
import com.zhuoshi.bean.WdHtProject;
import com.zhuoshi.bean.WdHtUnit;
import com.zhuoshi.mapper.WdHtBuildMapper;
import com.zhuoshi.mapper.WdHtProjectMapper;
import com.zhuoshi.mapper.WdHtUnitMapper;
import com.zhuoshi.service.WdHtUnitService;

/**
 * @author Alex 关于单元功能模块的的service
 */
@Service
public class WdHtUnitServiceImpl implements WdHtUnitService {

	@Autowired
	private WdHtUnitMapper WdHtUnitMapper;

	@Autowired
	private WdHtProjectMapper wdHtProjectMapper;
	
	@Autowired
	private WdHtBuildMapper wdHtBuildMapper;
	
	/**
	 *  查询全部的单元信息
	 */
	@Override
	public List<WdHtUnit> getAll(String buidId) {
		return WdHtUnitMapper.selectAll(buidId);
	}

	/**
	 * 查询全部的项目
	 */
	@Override
	public List<WdHtProject> getAllProject()
	{
		return wdHtProjectMapper.selectAll(null);
	}

	/**
	 * 查询全部的楼栋
	 */
	@Override
	public List<WdHtBuild> getAllBuild(String projectId)
	{
		return wdHtBuildMapper.selectAll(projectId);
	}

	/**
	 * 添加一个单元的操作
	 */
	@Override
	public int add(WdHtUnit WdHtUnit) {
		
		return WdHtUnitMapper.insertSelective(WdHtUnit);
	}

	/**
	 * 修改一个单元的操作
	 */
	@Override
	public int upOne(WdHtUnit wdHtUnit) {
		
		return WdHtUnitMapper.updateByPrimaryKeySelective(wdHtUnit);
}
	/**
	 * 删除一个的操作
	 */
	@Override
	public int del(String unitId) {
		return WdHtUnitMapper.deleteByPrimaryKey(unitId);
	}
	
	/**
	 *  查询一个的功能
	 */
	@Override
	public WdHtUnit selectOne(String unitId) {
		
		return WdHtUnitMapper.selectByPrimaryKey(unitId);
	}
}
